package com.smarttable.ysd.floatwindow;

import wei.mark.standout.StandOutWindow;
import wei.mark.standout.constants.StandOutFlags;
import wei.mark.standout.ui.Window;

import android.content.Intent;
import android.media.AudioManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Toast;

import com.smarttable.ysd.R;

public class RotationWindow extends StandOutWindow {

	private ImageView mSoundImage;
	@Override
	public String getAppName() {
		return "Mute";
	}

	@Override
	public int getAppIcon() {
		return android.R.drawable.ic_menu_close_clear_cancel;
	}

	@Override
	public void createAndAttachView(int id, FrameLayout frame) {
		// create a new layout from body.xml
		LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.rotation_window, frame, true);
		mSoundImage = (ImageView)frame.findViewById(R.id.sound);
	}

	// the window will be centered
	@Override
	public StandOutLayoutParams getParams(int id, Window window) {
		return new StandOutLayoutParams(id, 96, 96,
				StandOutLayoutParams.LEFT, StandOutLayoutParams.BOTTOM);
	}

	// move the window by dragging the view
	@Override
	public int getFlags(int id) {
		return super.getFlags(id) | StandOutFlags.FLAG_BODY_MOVE_ENABLE
				| StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE;
	}

	public void rotation(View view){
		SelectRotation mRotation = new SelectRotation(
				getApplicationContext());
		int status = mRotation.setRotation();
		Intent intentR = new Intent();
		intentR.setAction("com.android.zy.rotation");
		intentR.putExtra("status", status);
		sendBroadcast(intentR);
	}
	
}
